﻿#include "editor/settings.h"
#include "editor/drawing/tool.h"
#include "editor/drawing/pen.h"
#include "font.h"

using namespace std;
using namespace anip;
using namespace anip::editor;

Font Settings::defaultFont{};
Font Settings::headerFont{};
PreloadedTexture Settings::closeButtonTexture("ui\\close.png");
PreloadedTexture Settings::folderIconTexture("ui\\folder.png");

const vector<drawing::Tool*> Globals::drawingTools
{
	new drawing::PointerTool(),
	new drawing::PenTool()
};

DrawingArea* Globals::currentDrawingArea = nullptr;
DrawingToolbox* Globals::drawingToolbox = nullptr;
DrawingToolbar* Globals::drawingToolbar = nullptr;
Inspector* Globals::inspector = nullptr;

EditorWindow::EditorWindow(Container* parent, invec2 size, const wstring& title) :
	ui::Window(parent, size)
{
	setInheritFont(Settings::defaultFont);
	setFont(Settings::headerFont);
	setText(title);
	setPosition({ 100, 100 });
}

void Settings::initDefault()
{
	cout << "Loading resources..." << endl;
	Shared::preloadObjects();

	FontManager::addFace("ui", "fonts/arial.ttf");
	FontManager::addFace("chs", "fonts/simhei.ttf");
	FontManager::init();
	Font f = FontManager::get({ "ui", "chs" }, 16);

	defaultFont = f;
	headerFont = f;
}

void Globals::init()
{

}

void Globals::finalize()
{
	for (auto t : drawingTools)
		delete t;
}